import {lazy, Suspense} from "react";
import {useRoutes} from "react-router-dom";

const Home = lazy(() => import('@/views/Home/Home.jsx'));
const Login = lazy(() => import('@/views/Login/Login.jsx'));
const NotFount = lazy(() => import('@/views/NotFount/NotFount'));

function load(Com) {
    return (
        // <Suspense fallback={<div>组件正在加载中....</div>}>
        //     <Com/>
        // </Suspense>
        <Com/>
    )
}

// 动态路由
const useGetRouter = [
    {
        path: '/',
        element: load(Home)
    },
]

// 静态路由
const staticRouter = [
    {
        path: '/login',
        element: load(Login)
    },
    {
        path: '*',
        element: load(NotFount)
    }
]

export default function () {
    return useRoutes([...staticRouter, ...useGetRouter]);
}